package com.gh.rabbitmq.seven;

import com.gh.rabbitmq.utils.RabbitmqUtils;
import com.rabbitmq.client.Channel;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Author Eric
 * @Date 2021/7/18 17:06
 * @Version 1.0
 */
public class EmitLogTopic {
    public static final String EXCHANGE_NAME="topic_logs";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitmqUtils.getChannel();
        Map<String,String> map=new HashMap<>();
        map.put("quick.orange.rabbit","Q1Q2");
        map.put("lazy.orange.elephant","Q1Q2");
        map.put("quick.orange.fox","Q1");
        map.put("lazy.brown.fox","Q2");
        map.put("lazy.pink.rabbit","Q2");
        map.put("quick.brown.fox","无");
        map.put("quick.orange.male.rabbit","无");
        map.put("lazy.orange.male.rabbit","Q2");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String routingKey = entry.getKey();
            String message = entry.getValue();
            channel.basicPublish(EXCHANGE_NAME,routingKey,null,message.getBytes());
            System.out.println("生产者发出消息:"+entry.getValue());
        }
    }
}
